import com.zaxxer.hikari.HikariDataSource;

import java.sql.SQLException;

public class Hello {
    public static void main(String[] args) {

        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/jdbc");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setMaximumPoolSize(10);
        dataSource.setMinimumIdle(1);
        dataSource.setIdleTimeout(30000);
        dataSource.setConnectionTimeout(30000);
        dataSource.setMaxLifetime(60000);
        dataSource.setPoolName("MyHikariPool");
        dataSource.setConnectionTestQuery("SELECT 1");
        dataSource.setValidationTimeout(30000);


        try {
            if(dataSource.getConnection() != null){
                System.out.println("连接成功");
            }else{
                System.out.println("连接失败");
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }

}
